package com.nami.dispatcher.controller.middleware.mq.consumer;

import com.nami.dispatcher.facade.user.L1UserCacheDelFacade;
import com.nami.gate.external.basic.constants.UpdCacheTopicConst;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@AllArgsConstructor
@RocketMQMessageListener(topic = UpdCacheTopicConst.REFRESH_USER_TOPIC,
    consumerGroup = UpdCacheTopicConst.REFRESH_USER_DISPATCHER_CONSUMER_GROUP,
    messageModel = MessageModel.BROADCASTING, consumeMode = ConsumeMode.CONCURRENTLY)
public class RefreshUserCacheConsumer implements RocketMQListener<String> {

    private final L1UserCacheDelFacade userCacheDelCmdExe;

    /**
     * 目前为广播
     *
     * @param body
     */
    @Override
    public void onMessage(String body) {
        try {
            userCacheDelCmdExe.execute(body);
        } catch (Exception var2) {
            var2.printStackTrace();
            log.error("[qos] 出现错误：{}", var2);
        }

    }


}
